package com.example.folkmqdemo.controller;

import org.noear.folkmq.client.MqClient;
import org.noear.folkmq.client.MqMessage;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.io.IOException;

@RestController
public class TestController {

    @Autowired
    MqClient mqClient;
    @GetMapping("/create")
    public Boolean createUser(@RequestParam String userId){
        try {
            mqClient.publish("event.user.created",new MqMessage("用户id=>"+userId));
            return true;
        } catch (IOException e) {
            System.out.println(e.getMessage());
            return false;
        }
    }
}
